//
//  ViewController.m
//  06-活动指示器
//
//  Created by J on 16/2/27.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIView *orangeView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    CAReplicatorLayer* repLayer = [CAReplicatorLayer layer];
    repLayer.frame = _orangeView.bounds;
    [_orangeView.layer addSublayer:repLayer];
    
    CALayer* layer = [CALayer layer];
    layer.transform = CATransform3DMakeScale(0, 0, 0);
    layer.position = CGPointMake(_orangeView.bounds.size.width/2.0, 20);
    layer.bounds = CGRectMake(0, 0, 10, 10);
    layer.backgroundColor = [UIColor purpleColor].CGColor;
    [repLayer addSublayer:layer];
    

    
    CGFloat duration = 1.0;
    int count = 20;
    CGFloat angle = M_PI*2/count;
    
    //设置子层总数
    repLayer.instanceCount = count;
    repLayer.instanceDelay = duration/count;
    repLayer.instanceTransform = CATransform3DMakeRotation(angle, 0, 0, 1);
    
    
    //设置缩放动画
    CABasicAnimation* ani = [CABasicAnimation animation];
    ani.keyPath = @"transform.scale";
    ani.toValue = @0;
    ani.fromValue = @1;
    ani.duration = duration;
    ani.repeatCount = MAXFLOAT;
    
    [layer addAnimation:ani forKey:nil];
    
    
    }



@end
